#include <iostream>
using namespace std;
#define int long long
 
signed main()
{
	int n = 0, m = 0, a = 0, b = 0;
	cin >> n >> m >> a >> b;
	int res = 0;
    // 2x + 3y = ? 条件太少就枚举
    for(int x = 0; x <= min(n / 2, m); ++x) // 枚举x
    {
        int y = min(n - 2 * x, (m - x) / 2);
        res = max(res, a * x + b * y);
    }
	cout << res << endl;
	return 0;
}